Skip to main content

Image to Image SDXL

Stable Diffusion 1.5's image-to-image capability allows you to modify or transform existing images using text descriptions. It's like having a digital paintbrush that can be guided by your words.


import requests
import json
url = "https://api.imagepipeline.io/sdxl/image2image/v1"
headers = {
"API-Key": "Your API Key"
}
data = {
"model_id": "sdxl",
"init_image": "https://docs.imagepipeline.io/img/sdxl_img2img.png",
"prompt": "ethereal fantasy concept art of woman with crown of beautiful flowers, 8k quality, majestic, magical, fantasy art, cover art, dreamy",
"negative_prompt": "photographic, realistic, realism, 35mm film, dslr, cropped, frame, text, ((deformed eyes)), glitch, noise, noisy, off-center, deformed, ((cross-eyed)), bad anatomy, ugly, disfigured, sloppy, duplicate, mutated, black and white",
"num_inference_steps": 45,
"refiner": true,
"samples": 1,
"guidance_scale": 10,
"width": 768,
"height": 768,
"seed": 12345,
"safety_checker": true
}
response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())

JSON Parameters

ParameterPermissible valuesNotes
model_idstrmodel_id can be found in models page. Filter by SDXL models
promptstr, 75 tokensCheck our Prompt Guide for tips
negative_promptstr, 75 tokensCheck our Prompt Guide for tips
num_inference_stepsint, [1-100]Noise is removed with each step, resulting in a higher-quality image over time. Ideal value 20-30
strengthfloat, [0-1]Optional denoise strength
samplesint, [1-4]Generates a maximum of 4 samples per API call
guidance_scalefloat, [1-20]Higher guidance scale prioritizes text prompt relevance but sacrifices image quality. Ideal value 7.5-12.5
widthintWidth in pixels. Higher than or equal to 768 for best results
heightintHeight in pixels. Higher than or equal to 768 for best results
init_imagestrAdd a publicly available link to the image you want to edit
seedintControlling the seed can help you generate reproducible images
safety_checkerbooleanChecks for NSFW images and filters explicit images

Status

Your response will include a status.

  • If the status = SUCCESS, you will also have download_urls that will have the links to your generated image based on the number of samples you have entered. The maximum number of samples that can be generated is 4.
  • If the status = PENDING, you will receive a id. You can use the status endpoint to fetch your image using the id.
  • If the status = FAILURE, you will receive only an error message.

Endpoint:

  • https://api.imagepipeline.io/sdxl/image2image/v1/status/{{id}}

Pass the API-Key as the authorization in the header.